Deprecate `cargo update foo`
authorAlex Crichton <alex@alexcrichton.com>
Sat, 27 Sep 2014 04:24:31 +0000 (21:24 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 29 Sep 2014 23:54:45 +0000 (16:54 -0700)
To maintain consistency with `cargo {build,test,bench,clean}` the `update`
subcommand now takes a specific package via the `-p` argument instead of as a
positional argument.

src/bin/update.rs
tests/test_cargo_compile_git_deps.rs

index d7fd67b5f56c304db30d76c50346312224252238..7424a471bf8c77c3e8b6b0850e3c97b5b3480e70 100644 (file)
@@ -10,21 +10,23 @@ docopt!(Options, "
 Update dependencies as recorded in the local lock file.
 
 Usage:
-    cargo update [options] [<spec>]
+    cargo update [options]
+    cargo update [options] <spec>
 
 Options:
-    -h, --help              Print this message
-    --aggressive            Force updating all dependencies of <name> as well
-    --precise PRECISE       Update a single dependency to exactly PRECISE
-    --manifest-path PATH    Path to the manifest to compile
-    -v, --verbose           Use verbose output
+    -h, --help               Print this message
+    -p SPEC, --package SPEC  Package to run benchmarks for
+    --aggressive             Force updating all dependencies of <name> as well
+    --precise PRECISE        Update a single dependency to exactly PRECISE
+    --manifest-path PATH     Path to the manifest to compile
+    -v, --verbose            Use verbose output
 
 This command requires that a `Cargo.lock` already exists as generated by
 `cargo build` or related commands.
 
-If <spec> is given, then a conservative update of the lockfile will be
-performed. This means that only the dependency specified by <spec> will be
-updated. Its transitive dependencies will be updated only if <spec> cannot be
+If SPEC is given, then a conservative update of the lockfile will be
+performed. This means that only the dependency specified by SPEC will be
+updated. Its transitive dependencies will be updated only if SPEC cannot be
 updated without updating dependencies.  All other dependencies will remain
 locked at their currently recorded versions.
 
@@ -34,22 +36,31 @@ being updated should be updated to. For example, if the package comes from a git
 repository, then PRECISE would be the exact revision that the repository should
 be updated to.
 
-If <spec> is not given, then all dependencies will be re-resolved and
+If SPEC is not given, then all dependencies will be re-resolved and
 updated.
 
-For more information about package ids, see `cargo help pkgid`.
+For more information about package id specifications, see `cargo help pkgid`.
 ",  flag_manifest_path: Option<String>, arg_spec: Option<String>,
-    flag_precise: Option<String>)
+    flag_precise: Option<String>, flag_package: Option<String>)
 
 pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
     debug!("executing; cmd=cargo-update; args={}", os::args());
     shell.set_verbose(options.flag_verbose);
     let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
 
+    let spec = if options.arg_spec.is_some() {
+        let _ = shell.warn("`cargo update foo` has been deprecated in favor \
+                            of `cargo update -p foo`. This functionality \
+                            will be removed in the future");
+        options.arg_spec.as_ref()
+    } else {
+        options.flag_package.as_ref()
+    };
+
     let mut update_opts = ops::UpdateOptions {
         aggressive: options.flag_aggressive,
         precise: options.flag_precise.as_ref().map(|s| s.as_slice()),
-        to_update: options.arg_spec.as_ref().map(|s| s.as_slice()),
+        to_update: spec.map(|s| s.as_slice()),
         shell: shell,
     };
 
index 8bab2b417c815394a0f16a16150122c4d45d11bc..1ab1f0e85020ae957fff33c4b9e0253504acdec1 100644 (file)
@@ -830,7 +830,8 @@ test!(two_deps_only_update_one {
     add(&repo);
     commit(&repo);
 
-    assert_that(project.process(cargo_dir().join("cargo")).arg("update").arg("dep1"),
+    assert_that(project.process(cargo_dir().join("cargo")).arg("update")
+                       .arg("-p").arg("dep1"),
         execs()
         .with_stdout(format!("{} git repository `{}`\n",
                              UPDATING, git1.url()))